package com.yufei.pfw.service;

import org.springframework.data.mongodb.core.query.Field;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Sort;

import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;

/**
 * @author jasstion
 * 下午3:08:45
 */
public class MyQuery extends Query{
private Sort mySort=new Sort();
private int limit=0;
public Sort getMySort() {
	return mySort;
}
public void setMySort(Sort mySort) {
	this.mySort = mySort;
}
private int skip=0;
	public MyQuery(int limit,int skip,Sort sort) {
		super();
		// TODO Auto-generated constructor stub
		this.mySort=sort;
		this.limit=limit;
		this.skip=skip;
	}
	public MyQuery() {
		super();
		// TODO Auto-generated constructor stub
	}
	@Override
	public DBObject getSortObject() {
		// TODO Auto-generated method stub
		if(mySort==null){
			return new BasicDBObject();
		}
   
		return mySort.getSortObject();
	}
	@Override
	public int getSkip() {
		// TODO Auto-generated method stub
		return skip;
	}
	@Override
	public int getLimit() {
		// TODO Auto-generated method stub
		return limit;
	}

	
	public void setLimit(int limit) {
		this.limit = limit;
	}
	public void setSkip(int skip) {
		this.skip = skip;
	}
	private Field myField;
	public Field getMyField() {
		return myField;
	}
	public void setMyField(Field myField) {
		this.myField = myField;
	}
	public DBObject getFieldsObject() {
		if (this.myField == null) {
			return null;
		}
		return myField.getFieldsObject();
	}


}
